package IOStream;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/* java.io.ObjectInputStream
   对象输入流,可以进行对象反序列化 读取一组字节并还原成对象
   OIS读取的字节 必须是有OOS将对象序列化得到的字节否则会抛异常
 */

public class OISDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        FileInputStream fis=new FileInputStream("Demo.txt");
        ObjectInputStream ois=new ObjectInputStream(fis);

        //对象反序列化 返回的是object类型
        Object person=(Person)ois.readObject();
        System.out.println(person);

    }

}
